define(['app'],function(app){return {module: function($scope, $http, eventBusService, httpService, params) {
	
	$scope.form.id = params.id;
	$scope.form.fk_user = params.fk_user;
	//查询所有单位
	httpService.post(app.urls.user_unit_selectCenterAndSchool,$scope.form,function(data){
		if("0000" === data.code){
			$scope.units = data.data;
			$scope.find();
		}else{
			alert(data.msg);
		}
	});
	
	//查询教职工单位数据
	$scope.find = function(){
		httpService.post(app.urls.user_unit_selectByid,$scope.form,function(data){
			if("0000" === data.code){
    			$scope.form = data.data;
    		}else{
    			alert(data.msg);
    		}
		});
	}
	
	$scope.saveForm = function(){
		if($scope.formCheck()) {
			httpService.post(app.urls.user_unit_updateByid,$scope.form, function (data) {
				if ("0000" === data.code) {
					eventBusService.publish("content.page.reload", data);
					eventBusService.publish("modal.page.close", {});
				} else {
					alert(data.msg);
				}
			});
		}
	}
	
}}});